import { createApp } from 'vue'
import { createPinia } from 'pinia'
import './styles/index.scss'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { configInstance } from '@/AGC/config/agconnect-services'
// Pinia 持久化插件
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import App from '@/App.vue'
import router from '@/router'
// 1. 引入组件
import { Picker, Field, Popup, Search } from 'vant'
// 2. 引入组件样式
import 'vant/lib/index.css'
import '@vant/touch-emulator'
import agconnect from '@hw-agconnect/api'

// 调用SDK的初始化方法
configInstance()
// 设置AGC登录用户信息存储方式
agconnect.auth().setUserInfoPersistence(1)

const app = createApp(App)

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 创建 Pinia 实例
const pinia = createPinia()
// 应用 Pinia 插件
pinia.use(piniaPluginPersistedstate)
app.use(pinia)
app.use(router)
// 3. 注册你需要的组件
app.use(Picker)
app.use(Field)
app.use(Popup)
app.use(Search)
// app.use(showConfirmDialog)

app.mount('#app')
